<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <my-header>
        </my-header>
        <Head-Son></Head-Son>
    </div>
    <template id="header">
        <div>
            <button @click="al">点击</button>
        </div>

    </template>


    <!-- //局部组件 -->
    <template id="headSon">
        <div>
            <button @click="sdfasfsd">点击局部组件</button>
        </div>
    </template>
    <script>
        let HeadSon = {
            name: "HeadSon",
            template: "#headSon",
            data() {
                return {
                    clickName: "zjasdnfsd",
                }
            },
            methods: {
                sdfasfsd() {
                    console.log(this.clickName);
                }

            }
        }


        Vue.component("my-header", {
            template: "#header",
            data() {
                return {
                    name: "张三丰"
                }
            },
            methods: {
                al() {
                    alert(this.name)
                }
            }
        })
        const app = new Vue({
            el: "#app",
            data: {

            },
            components: {
                HeadSon,
            }

        })
    </script>
</body>

</html>